package com.localjoycommunity.cpdj.project.system.controller;

import com.localjoycommunity.cpdj.common.interceptor.help.NeedLogin;
import com.localjoycommunity.cpdj.framework.web.controller.BaseController;
import com.localjoycommunity.cpdj.framework.web.page.TableDataInfo;
import com.localjoycommunity.cpdj.project.system.domain.*;
import com.localjoycommunity.cpdj.project.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author: lida
 * @Date: 2020/11/14 0014 上午 11:53
 * @Description:
 */
@RequestMapping("/system/users/center")
@RestController
public class UserCenterController extends BaseController {

    @Autowired
    private IUserCompanyService userCompanyService;
    @Autowired
    private IUserBeautyService userBeautyService;
    @Autowired
    private IUserNewsService userNewsService;
    @Autowired
    private IUserDataService userDataService;
    @Autowired
    private IUserCourseService userCourseService;


    /**
     * 我的收藏
     */
    @NeedLogin
    @GetMapping("/collect")
    public TableDataInfo collect(HttpServletRequest req) {
        startPage();
        Integer userId = getUserId(req);
        List<TwoNewOrganization> list = userCompanyService.selectUserCollect(userId);
        return getDataTable(list);
    }

    /**
     * 我的点赞风采
     */
    @NeedLogin
    @GetMapping("/beauty")
    public TableDataInfo beauty(HttpServletRequest req) {
        startPage();
        Integer userId = getUserId(req);
        List<SysBeauty> list = userBeautyService.selectUserBeauty(userId);
        return getDataTable(list);
    }

    /**
     *我的点赞信息速览
     */
    @NeedLogin
    @GetMapping("/news")
    public TableDataInfo news(HttpServletRequest req) {
        startPage();
        Integer userId = getUserId(req);
        List<SysNews> list = userNewsService.selectUserNews(userId);
        return getDataTable(list);
    }

    /**
     * 我的资料
     */
    @NeedLogin
    @GetMapping("/data")
    public TableDataInfo data(HttpServletRequest req) {
        startPage();
        Integer userId = getUserId(req);
        List<SysLearnData> list = userDataService.selectUserData(userId);
        return getDataTable(list);
    }

    /**
     * 我的课程
     */
    @NeedLogin
    @GetMapping("/course")
    public TableDataInfo course(HttpServletRequest req) {
        startPage();
        Integer userId = getUserId(req);
        List<SysCourse> list = userCourseService.selectUserCourse(userId);
        return getDataTable(list);
    }
}
